#ifndef __SCENE_OBJECT_H__
#define __SCENE_OBJECT_H__

#pragma once

#include "ControlledObject.h"
#include "RenderingConfig.h"

namespace Nezha
{

	enum SceneObjectUpdate
	{
		SOU_WORLDTRANSFORM = 0x1,
		SOU_WORLDTRANSFORM_MATRIX = 0x2,
		SOU_CHILDREN = 0x4,
		//SOU_PARENT_NOTIFIED = 0x20,

		SOU_BOUND = 0x100,
		SOU_BOUND_UPWARD = 0x200,

		SOU_CONTROLLER = 0x1000,
	};

	const u32 TransformUpdateBits = 0xFF;
	const u32 BoundUpdateBits = 0xFF00;

	class RenderObject;

	/** Scene object base. */
	class GRAPHICS_ENTRY SceneObject : public ControlledObject
	{
		friend class SceneNode;
	public:
		virtual ~SceneObject(){}

		// override this for correctly runtime type info.
		virtual int getSceneObjectType() const
		{
			return SOT_UNUSABLE;
		}

		virtual RenderObject* getRenderObject();

		virtual void update(float dt) {}

		SceneNode* getSceneNode();

		SceneNode* getParentSceneNode();

		u16 getLOD() const;

NEZHA_INTERNAL:
		void _internalSetLod(u16 lod);

	protected:
		SceneObject(const _string& name);

		virtual void _onAttach(SceneNode* sn){}

		virtual void _onDetach(){}

	private:
		u16 mLod;
		SceneNode* mBindedSceneNode;

		// only for scene graph & scene node
		void bind2SceneNode(SceneNode* sn);
	};

	inline SceneNode* SceneObject::getSceneNode()
	{
		return mBindedSceneNode;
	}

	inline u16 SceneObject::getLOD() const
	{
		return mLod;
	}

	typedef RefCountedPtr<SceneObject>::Default SceneObjectPtr;

}//end namespace Nezha

#endif //end __SCENE_OBJECT_H__